package com.ideyatech.allowancereceipts.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;



import com.ideyatech.allowancereceipts.entity.Establishment;

public class EstablishmentValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return Establishment.class.isAssignableFrom(clazz);
	}

	public void validate(Object clazz, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.required", new Object[]{"Name"});
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "taxIDNumber", "error.required", new Object[]{"TIN"});
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address", "error.required", new Object[]{"Address"});
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "municipality", "error.required", new Object[]{"Municipality"});
	}

}
